package com.example.startservice2;

import android.app.Service;
import android.content.Intent;
import android.media.MediaParser;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
    MediaPlayer mediaPlayer;
    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i("msg","onBind");
        return  null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i("msg","onCreate");
        mediaPlayer=MediaPlayer.create(getApplicationContext(),R.raw.call);
    }

    @Override
    public void onDestroy() {
        Log.i("msg","onDestroy");
        mediaPlayer.stop();
        super.onDestroy();

    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("msg","onUnbind");
        return super.onUnbind(intent);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i("msg","onStartCommand");
        mediaPlayer.start();
        return super.onStartCommand(intent, flags, startId);
    }
}
